package sanrenxing.dayEnd.backRepertoryTotal.dao;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import sanrenxing.dayEnd.backRepertoryTotal.domain.SettingOfSecurities;

import java.util.List;
import java.util.Map;

/**
 * 功能：券商设置数据层接口
 * 编写者：蒋玲苹
 * 日期：
 * 版本：1.0
 */
@Repository
public interface SettingOfSecuritiesDao {
    /**
     * 添加数据
     * @param settingOfSecurities
     * @return
     */
    @Insert("insert into settingOfSecurities values(#{stockId},#{stockName},#{explain},#{notes})")
    public int add(SettingOfSecurities settingOfSecurities);

    /**
     * 删除数据
     * @param stockId
     * @return
     */
    @Delete("delete from settingOfSecurities where stockId=#{stockId}")
    public int delete(@Param("stockId") String stockId);

    /**
     * 修改数据
     * @param settingOfSecurities
     * @return
     */
    @Update("update settingOfSecurities set stockId=#{stockId},stockName=#{stockName},explain=#{explain},notes=#{notes} where stockId=#{stockId}")
    public int update(SettingOfSecurities settingOfSecurities);

    /**
     * 查询所有数据
     * @param map
     * @return
     */
    @Select("<script>" +
            "select * from " +
            " (select rownum rn,settingOfSecurities.* from settingOfSecurities " +
            " <where>#{end}>=rownum</where>)" +
            "<where>" +
            "<if test='settingOfSecurities.stockName!=null'>" +
            " and stockName like '%${settingOfSecurities.stockName}%'" +
            "</if>" +
            " and rn>=#{start}" +
            "</where>" +
            "</script>")
    public List<SettingOfSecurities> queryAll(Map<String, Object> map);
    /**
     * 统计记录数
     * @param
     * @return 记录行数据
     */
    @Select("select count(*) from settingOfSecurities")
    public int count();

}
